import { Component } from 'react';
import React from 'react';
import { connect } from 'umi';

import HighPerformTable from '@/components/HighPerformTable';
import KeywordFilterSearch from '@/components/KeywordFilterSearch';
import { Button } from 'antd';
import { PlusOutlined } from '@ant-design/icons';
import APIS from '@/apis';

class ExamCheckStudents extends Component<any, any> {
    actionRef: any;
    paper: any;

    requestGetData(
        params: {
            pageSize?: number;
            current?: number;
        },
        sorter: {
            [key: string]: 'ascend' | 'descend';
        },
        filter: {
            [key: string]: React.ReactText[];
        },
    ) {

        return APIS.CheckAPI.GetResultList({ ...params, sorter, filter, examId: this.props.location.state.examId });
    }

    constructor(props: any) {
        super(props);
    }

    componentDidMount() { }

    clomns: any = [
        {
            title: '学生',
            dataIndex: 'nickname',
        },
        {
            title: '是否批阅',
            dataIndex: 'checkStarte',
            render: (e: any, record: any) => (
                record.checkState === 1 ? '是' : '否'
            )
        },
        {
            title: '分数',
            dataIndex: 'score',
            render: (e:any,record:any) => (
                record.checkState === 1?record.score:'未批改'
            )
        },
        {
            title: '操作',
            dataIndex: 'action',
            render: (e: any, record: any) => (
                record.checkState === 1 ? <Button disabled>
                    已批改
                      </Button> :
                    <Button type={"primary"}
                        onClick={() => {
                            this.props.history.push({
                                pathname: `/teaching/check/studentsTestPaper`,
                                state: {
                                    examId: record.examId,
                                    paperId: this.props.location.state.paperId,
                                    studentId: record.studentId,
                                    description: this.props.location.state.description
                                }
                            });

                        }}
                    >
                        批改
                          </Button>

            )
        },

    ];
    handleDataImport() { }
    handleDataExport() { }
    render() {
        return (
            <div>
                {/* <KeywordFilterSearch
                    filters={[
                        // {
                        //     title: '学院',
                        //     multiple: false,
                        //     keywords: ['全部', '计算机学院', '轨道交通学院', '电气工程学院'],
                        // },
                        { title: '年级', multiple: false, keywords: ['全部', '2015', '2016', '2017', '2018'] },
                    ]}
                ></KeywordFilterSearch> */}
                <HighPerformTable<any>
                    ref={(ref) => (this.actionRef = ref)}
                    requestGetData={this.requestGetData.bind(this)}
                    additionOptions={[
                        {
                            title: '查看',
                            onClick: (record: any) => {

                            },
                        },
                    ]}
                    toolBarRender={() => [
                        //             <Button key={0} type="primary" onClick={() => this.actionRef.handleModalVisible(true)}>
                        //                 <PlusOutlined /> 新增班级
                        // </Button>,
                        //             <Button key={1} type="primary" onClick={() => this.handleDataImport()}>
                        //                 批量导入
                        // </Button>,
                        //             <Button key={2} type="primary" onClick={() => this.handleDataExport()}>
                        //                 批量导出
                        // </Button>,
                    ]}
                    columns={this.clomns}
                    action={true}

                />
            </div>
        );
    }
}

export default connect()(ExamCheckStudents);
